import os
import pandas as pd

# 测试用例数据
data = {
    "用例编号": ["TC-US001", "TC-US002", "TC-US003", "TC-US004", "TC-US005"],
    "测试场景": ["按登录名精确搜索", "按姓名组合搜索", "按手机号精确搜索", "按商务电话精确搜索", "按管理员登录名搜索"],
    "登录名": ["WM01", "", "", "", "ZS01"],
    "姓氏": ["", "Zhang", "", "", ""],
    "名字": ["", "San", "", "", ""],
    "商务电话": ["", "", "", "0755-88886666", ""],
    "手机": ["", "", "13789012345", "", ""],
    "状态": ["不选择", "不选择", "不选择", "不选择", "不选择"],
    "预期结果": [
        "搜索结果包含\"王梅\"用户，登录名显示为\"WM01\"",
        "搜索结果包含\"张三\"用户，姓名显示为\"Zhang San\"",
        "搜索结果包含\"陈晓\"用户，手机号码显示为\"13789012345\"",
        "搜索结果包含\"刘伟\"用户，商务电话显示为\"0755-88886666\"",
        "搜索结果包含\"张三\"用户，登录名显示为\"ZS01\"，并标注管理员权限标识"
    ]
}

# 创建DataFrame
df = pd.DataFrame(data)

# 定义保存路径（与之前一致的文件夹结构）
folder = "D:\\pycharm\\PM_test\\Excel"
if not os.path.exists(folder):
    os.makedirs(folder)

# 保存为Excel文件
file_path = os.path.join(folder, "user_search_test_matrix.xlsx")
df.to_excel(file_path, index=False, sheet_name="用户搜索功能测试矩阵")

print(f"测试用例表已保存至：{file_path}")